layui.use(['form','layer'],function(){
	var form = layui.form,layer = layui.layer;
	
	
	$("#save-btn").on('click',function(){save();});
	initPara();
	function initPara(){
		
		var operateData = $("#operateData").val();
		if(!isBlank(operateData))
			$("#paraOper").val(operateData);
		var data = [];
		parent.$("input[name='data-input']").each(function(){
			var paraName = parent.$(this).val();
			if(!isBlank(paraName))
			data.push({'paraName':parent.$(this).val()})
		});
		var content = [];
		 for(var i = 0 ;i < data.length;i++){
         	content.push("<tr><td>"+data[i].paraName+"</td></tr>")
         }
		 
	         $("#dg").append(content.join(""));
		/*ajaxPost('../para/getOperCrData',data,
				function(data){
                    var para = data.data;
                    var content = [];
                    for(var i = 0 ;i < para.length;i++){
                    	content.push("<tr><td>"+para[i].paraName+"</td></tr>")
                    }
			         $("#dg").append(content.join(""));
				},
				function(data){
					parent.layer.alert(data.errorMsg, {
    					icon: 5,
    					title: "错误"
    					});
				});*/
	}
	
	function save(){
		var paraOper = $("#paraOper").val();
		if(isBlank(paraOper)){
			layer.tips("请填写运算公式","#paraOper",{
  			  tips: [1, '#FF0000'],
  			  time: 3000
  			});
		isValidated = false;
  		return false;
		
		}
		var index = $("#index").val();
		if(isBlank(index)){
			layer.alert("页面传值失败，请重新打开页面", {
				icon: 5,
				title: "错误"
				});
			return false;
		}
		var selectType = $("#selectType").val();
		if(selectType == 1){
			parent.$("#dg>tr:eq("+index+")").find("input[name='outputData']").val(paraOper);
			parent.$("#dg>tr:eq("+index+")").find("input[name='data-output']").val(paraOper);
		}
		var idx = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		parent.layer.close(idx);
	}
	
	
	
});